package xiaohu;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.io.File;

public class Test {
    public static void main(String[] args) {
        String filePath1 = "x1.xlsx";
        File file = new File(filePath1);
        if (!file.exists()) {
            System.out.println("文件不存在");
            return;
        } else {
            System.out.println(file.getAbsolutePath());
        }
        EasyExcel.read(filePath1, DataModel.class, new AnalysisEventListener<DataModel>() {
            @Override
            public void invoke(DataModel dataModel, AnalysisContext analysisContext) {
                System.out.println("解析到一条数据: " + dataModel);
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext analysisContext) {
                System.out.println("读取完毕");
            }
        }).sheet().doRead();
    }
}
